{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1426
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
   i,n,m,k,j:longint;
   a,p:array[0..2010] of longint;
 
procedure sort(l,r:longint);
var
   i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
      while a[i]<x do inc(i);
      while a[j]>x do dec(j);
      if i<=j then begin
         y:=a[i];
         a[i]:=a[j];
         a[j]:=y;
         inc(i);
         dec(j);
      end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
 
procedure sortP(l,r:longint);
var
   i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=p[(l+r) div 2];
repeat
      while p[i]<x do inc(i);
      while p[j]>x do dec(j);
      if i<=j then begin
         y:=p[i];
         p[i]:=p[j];
         p[j]:=y;
         inc(i);
         dec(j);
      end;
until i>j;
if l<j then sortP(l,j);
if i<r then sortP(i,r);
end;
 
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
read(n,m);
k:=n*m;
for i:=1 to k do read(p[i]);
sortP(1,k);
read(n);
for i:=1 to n do read(a[i]);
sort(1,n);
i:=1;
j:=1;
while (i<=n) and (j<=k) do begin
      while (a[i]>p[j]) and (i<=n) and (j<=k) do inc(j);
      if j<=k then begin
         inc(i);
         inc(j);
      end;
end;
writeln(i-1);
end.